<?php
// $Id$

/**
 * Controller_Admin_Somestuffs 控制器
 */
class Controller_Admin_Somestuffs extends Controller_Abstract
{

    function actionIndex()
    {
        //这里是搜索字段和操作符，like就是模糊搜索了，=就是严格等于，很好理解
        $wheres = array('key'=>'like',);
        $this->_getJQGridData(Somestuff::find(), $wheres);
    }


    function actionRemove() {
        $user = Helper_RBAC::get('user');
        $roles = Helper_RBAC::roles('user');
        //        dump($role);
        $idset = FUNC::getIdset($this->_context->idset);
        foreach($idset as $id) {
            $record = Somestuff::find('stuff_id = ?', $id)->one()->query();
            if(in_array('ADMIN', $roles)) {
                Somestuff::meta()->destroyWhere('stuff_id = ?', $id);
            }
        }
    }

    function actionEdit() {
        $stuff = Somestuff::find('stuff_id = ?', $this->_context->id)->one()->query();
        $this->_view['stuff'] = $stuff;
    }

    function actionSave() {
        $stuff = Somestuff::find('stuff_id = ?', $this->_context->stuff_id)->one()->query();
        $stuff -> key = $this->_context->key;
        $stuff -> value = $this->_context->value;
        $stuff -> desc = $this->_context->desc;
        $stuff -> save();

        //        dump($stuff);
    }

}


